package com.example.travel.Controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 功能：
 * 作者：lln
 * 日期：2025/3/18 10:53
 */
@RestController
@RequestMapping("/")
public class SessionController {

    @PostMapping("/checkSession")
    public Map<String, Object> checkSession(@RequestBody Map<String, String> requestBody) {
        String sessionId = requestBody.get("sessionId");
        // 检查 sessionId 是否有效
        if (isValidSession(sessionId)) {
            return Map.of("code", 200, "message", "Session is valid");
        } else {
            return Map.of("code", 401, "message", "Session is invalid");
        }
    }

    private boolean isValidSession(String sessionId) {
        // 实现 sessionId 的验证逻辑
        return true; // 示例代码，实际需要根据业务逻辑实现
    }
}
